<span page-title>{{ 'Apply Errata to Content Hosts' | translate }}</span>

<h3 translate>Apply to Content Hosts</h3>

<div data-extend-template="layouts/partials/table.html">
  <div data-block="list-actions">
    <button type="button" class="btn btn-primary"
            ng-click="goToNextStep()"
            ng-hide="denied('edit_hosts')"
            ng-disabled="table.numSelected == 0 || incrementalUpdates.length > 0">
      <span translate>Apply to Hosts</span>
    </button>
  </div>

  <div data-block="search-filter">
    <select class="form-control"
            ng-model="environmentFilter"
            ng-options="environment.id as environment.name for environment in environments"
            ng-change="selectEnvironment(environmentFilter)">
      <option value="" disabled selected >Filter by Environment</option>
    </select>


    <a ng-show="environmentFilter" ng-click="selectEnvironment(undefined)">
      <i class="fa fa-remove"></i>
    </a>
  </div>

  <div data-block="filters">
    <label class="checkbox-inline">
      <input type="checkbox" ng-model="restrictInstallable" ng-change="toggleInstallable()"/>
      <span translate>Only show content hosts where the errata is currently installable in the host's Lifecycle Environment.</span>
    </label>
  </div>

  <span data-block="no-rows-message" translate>
    No Content Hosts match this Erratum.
  </span>

  <span data-block="no-search-results-message" translate>
    Your search returned zero Content Hosts.
  </span>

  <div data-block="table">
    <p bst-alert="warning" ng-show="table.rows.length > 0 && stateIncludes('erratum.content-hosts.unavailable')">
      <span translate>The Content View or Lifecycle Environment needs to be updated in order to make errata available to these hosts.</span>
    </p>

    <div data-extend-template="layouts/select-all-results.html"></div>

    <table class="table table-striped table-bordered">
      <thead>
        <tr bst-table-head row-select>
          <th bst-table-column="name"><span translate>Name</span></th>
          <th bst-table-column="os"><span translate>OS</span></th>
          <th bst-table-column="environment"><span translate>Environment</span></th>
          <th bst-table-column="contentView"><span translate>Content View</span></th>
        </tr>
      </thead>

      <tbody>
        <tr bst-table-row ng-repeat="contentHost in table.rows" row-select="contentHost"
            ng-controller="ContentHostStatusController">
          <td bst-table-cell>
            <a ui-sref="content-host.info({hostId: contentHost.id})">
              {{ contentHost.name }}
            </a>
          </td>
          <td bst-table-cell>{{ contentHost.operatingsystem_name }}</td>
          <td bst-table-cell>{{ contentHost.content_facet_attributes.lifecycle_environment_name }}</td>
          <td bst-table-cell>{{ contentHost.content_facet_attributes.content_view_name || "" }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
